# -.- coding:utf-8 -.-
__author__ = 'vivi'

#多层框架/窗口定位

from selenium import webdriver
import time,os

driver = webdriver.Firefox()
file_path = 'file:///'+ os.path.abspath('frame.html')
driver.get(file_path)

driver.implicitly_wait(30)

#先找到iframe1(id=f1)
driver.switch_to_frame("f1")
driver.implicitly_wait(30)
#再找到嵌套在里面的inner.html文件里面的iframe2(id=f2)
driver.switch_to_frame("f2")

#然后正常的操作元素
driver.find_element_by_id('kw').send_keys('selenium')
driver.find_element_by_id('su').click()

time.sleep(2)

driver.quit()

